Handle 4-channel pixbufs when saving to jpeg.
authorMatthias Clasen <matthiasc@src.gnome.org>
Mon, 13 Sep 2004 23:34:34 +0000 (23:34 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 13 Sep 2004 23:34:34 +0000 (23:34 +0000)
gdk-pixbuf/ChangeLog
gdk-pixbuf/io-jpeg.c

index 16a1794dd90ca2e9d26b01ad4ac70714b9b15056..4c3952e758c6618e23791e5c9b7981578a7794bb 100644 (file)
@@ -1,3 +1,8 @@
+Mon Sep 13 19:31:34 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * io-jpeg.c (real_save_jpeg): Drop the alpha channel 
+       when saving 4-channel pixbufs.  (#152450, Emmanuel Pacaud)
+
 2004-09-09  Matthias Clasen  <mclasen@redhat.com>
 
        * makegdkpixbufalias.pl: Use the short prefix "IA__" for 
index 1a42feeb6bdb9a8f4f9d0095b223686b151d2f3d..1bf4bede113282d42b155b0d9fe0adef08185613 100644 (file)
@@ -872,6 +872,7 @@ real_save_jpeg (GdkPixbuf          *pixbuf,
        int i, j;
        int w, h = 0;
        int rowstride = 0;
+       int n_channels;
        struct error_handler_data jerr;
        ToFunctionDestinationManager to_callback_destmgr;
 
@@ -922,6 +923,7 @@ real_save_jpeg (GdkPixbuf          *pixbuf,
        }
        
        rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+       n_channels = gdk_pixbuf_get_n_channels (pixbuf);
 
        w = gdk_pixbuf_get_width (pixbuf);
        h = gdk_pixbuf_get_height (pixbuf);
@@ -994,7 +996,7 @@ real_save_jpeg (GdkPixbuf          *pixbuf,
        while (cinfo.next_scanline < cinfo.image_height) {
                /* convert scanline from ARGB to RGB packed */
                for (j = 0; j < w; j++)
-                       memcpy (&(buf[j*3]), &(ptr[i*rowstride + j*3]), 3);
+                       memcpy (&(buf[j*3]), &(ptr[i*rowstride + j*n_channels]), 3);
 
                /* write scanline */
                jbuf = (JSAMPROW *)(&buf);